﻿@page "/SlittingmachineDown"
@inject SlittingmachineServer slittingmachineServer
@using System.ComponentModel
@using AntDesign.TableModels
@inject ModalService _modalService
@inject MessageService _message
<h3>分切下料</h3>
<div>
    <Row>
        <Col Span="24">请选择分切机</Col>
    </Row>
    <Row>
        <Col Span="24">
        <Select style="width:100%" DataSource="@DataList"
                AllowClear="true"
                ValueOnClear="@(0)"
                @bind-Value="@selet"
                ValueName="@nameof(Slittingmachine_Entity.Deviceid)"
                LabelName="@nameof(Slittingmachine_Entity.Remark)">
        </Select>
        </Col>
    </Row>
    <Row>
        <Col Span="24">
        <label>请选择A轴需要的空卷心类型</label>
        </Col>
    </Row>
    <Row>
        <Col Span="24">
        <Select style="width:100%" DataSource="@MaterialNameDataList"
                AllowClear="true"
                ValueOnClear="@(0)"
                @bind-Value="@indexA"
                ValueName="@nameof(MaterialName_Entity.MaterialName)"
                LabelName="@nameof(MaterialName_Entity.Remark)">
        </Select>
        </Col>
    </Row>
    <Row>
        <Col Span="24">
        <label>请选择B轴需要的空卷心类型</label>
        </Col>
    </Row>
    <Row>
        <Col Span="24">
        <Select style="width:100%" DataSource="@MaterialNameDataList"
                AllowClear="true"
                ValueOnClear="@(0)"
                @bind-Value="@indexB"
                ValueName="@nameof(MaterialName_Entity.MaterialName)"
                LabelName="@nameof(MaterialName_Entity.Remark)">
        </Select>
        </Col>
    </Row>
    <Row>
        <Col Span="24">
        <Button style="width:100%" Type="@ButtonType.Primary" @onclick="@Creat">提交AB轴一起下料任务任务</Button>
        </Col>
    </Row>
    <br>
    <Row>
        <Col Span="24">

        <Button style="width:100%" Type="@ButtonType.Primary" @onclick="@CreatA">提交A轴下料任务任务</Button>

        </Col>
    </Row>
    <br>
    <Row>
        <Col Span="24">

        <Button style="width:100%" Type="@ButtonType.Primary" @onclick="@CreatB">提交B轴下料任务任务</Button>
        </Col>
    </Row>
</div>

@code {
    ObservableCollection<Slittingmachine_Entity> DataList { get; set; } = new ObservableCollection<Slittingmachine_Entity>();
    ObservableCollection<MaterialName_Entity> MaterialNameDataList { get; set; } = new ObservableCollection<MaterialName_Entity>();
    int selet { get; set; } = 0;
    int indexA { get; set; } = 0;
    int indexB { get; set; } = 0;


    protected override async Task OnInitializedAsync()
    {
        var Slittingmachines = await slittingmachineServer.Getlist();
        if (Slittingmachines != null)
        {
            DataList.Clear();
            foreach (var item in Slittingmachines)
            {
                DataList.Add(item);
            }
        }
        var MaterialNames = await slittingmachineServer.MaterialNamelist();
        if (MaterialNames != null)
        {
            MaterialNameDataList.Clear();
            foreach (var item in MaterialNames)
            {
                MaterialNameDataList.Add(item);
            }
        }


        base.OnInitialized();
    }
    private async Task Creat()
    {
        _modalService.Confirm(new ConfirmOptions()
        {
            Title = "提示",
            Icon =@<Icon Type="exclamation-circle" Theme="Outline"></Icon>,
OkText = "确认",
OnOk = async (e) =>
{
int a = selet;
int c = indexA;
var aa = await slittingmachineServer.TaskCreatDown(selet, indexA, indexB);
_message.Info(aa);
},
CancelText = "取消",
Content = "是否提交？",
});
}

private async Task CreatA()
{
_modalService.Confirm(new ConfirmOptions()
{
Title = "提示",
Icon =@<Icon Type="exclamation-circle" Theme="Outline"></Icon>,
OkText = "确认",
OnOk = async (e) =>
{
int a = selet;
int c = indexA;
var aa = await slittingmachineServer.TaskCreatDownone(selet, indexA, 1);
_message.Info(aa);
},
CancelText = "取消",
Content = "是否提交？",
});
}
private async Task CreatB()
{
_modalService.Confirm(new ConfirmOptions()
{
Title = "提示",
Icon =@<Icon Type="exclamation-circle" Theme="Outline"></Icon>,
OkText = "确认",
OnOk = async (e) =>
{
int a = selet;
int c = indexA;
var aa = await slittingmachineServer.TaskCreatDownone(selet, indexB, 2);
_message.Info(aa);
},
CancelText = "取消",
Content = "是否提交？",
});
}
}
